<!-- 商品列表组件 <address-list :list="xx"></address-list> -->
<template>
	<view class="content">
    <view class="addressBox" v-for="(item,index) in list" :key="index" >
      <delSlideLeft :item="item"  :data_transit="{index:index,item:item}"  @delItem="delItem">
        <view class="flex">
        <view class="edit"  @click="editAddress(item)">
          <view class="icon iconfont icon-bianji"></view>
        </view>
        <view class="status-box flex" v-if="chooseFlag" @click="chooseAddress(item)">
          <view v-if="JSON.parse(addressJson).addressId == item.addressId" class="icon iconfont icon-xuanzhong"></view>
          <view v-else class="icon iconfont icon-weixuanze"></view>
        </view>
        <view class="des flex" @click="editAddress(item)">
          <view class="largeAddress flex">
            <view v-if="item.isDefault" class="choose-box">默认</view>
            <view>{{item.destProvinceName}}{{item.destCityName}}{{item.destRegionName}}</view>
          </view>
          <view class="destAddress">{{item.destAddress}}</view>
          <view class="flex persion-des">
            <view class="name">{{item.destName}}</view>
            <view>{{item.destMobile}}</view>
          </view>
        </view>
        </view>
      </delSlideLeft>
    </view>
  </view>

</template>

<script>
	import dict from '@/static/js/dict.json'
  import delSlideLeft from '@/components/ay-operate/del_slideLeft.vue'
  import mRequest from "@/api/home"
	export default {
    components: {
      delSlideLeft,
    },
		props:{
			list: {
				type: Array,
				default(){
					return []
				}
			},
      chooseFlag: {
				type: Boolean,
				default: false,
			},
      orderFlag: {
				type: Boolean,
				default: false,
			},
      action: {
				type: String,
				default: false,
			},
      drugsList:{
        type: String,
				default: '',
      },
			addressJson: {
				type: String,
				default: '',
			},
      prescriptionId: {
				type: String,
				default: '',
			},
      hospTotalPrice: {
				type: String,
				default: '',
			},
      orderId:{
        type: String,
				default: '',
      },
      hospId: {
				type: String,
				default: '',
			},
		},
		methods: {
			// 跳转编辑地址
			editAddress(val){
				uni.navigateTo({
					url: `/pages/address/edit-address?addressId=${val.addressId}&addressJson=${this.addressJson}&chooseFlag=${this.chooseFlag}&prescriptionId=${this.prescriptionId}&hospTotalPrice=${this.hospTotalPrice}&hospId=${this.hospId}&orderId=${this.orderId}&orderFlag=${this.orderFlag}&drugsList=${this.drugsList}&action=${this.action}`,
					success: res => {},
					fail: () => {},
					complete: () => {},
				})
			},
      chooseAddress(val){
        console.log('wewewe')
        uni.redirectTo({
					url: `/pages/order/order?address=${JSON.stringify(val)}&addressJson=${this.addressJson}&chooseFlag=${this.chooseFlag}&prescriptionId=${this.prescriptionId}&hospTotalPrice=${this.hospTotalPrice}&hospId=${this.hospId}&orderId=${this.orderId}&orderFlag=${this.orderFlag}&drugsList=${this.drugsList}&action=${this.action}`,
					success: res => {},
					fail: () => {},
					complete: () => {},
				})
      },
       //点击删除按钮事件
       delItem: function(e) {
        console.log(e)
        let params = {
          addressId: e.item.addressId,
        }
        mRequest.deleteAddress(params).then(
          res => {
						console.log(res)
          },
          error => {
           this.mescroll.endErr();
          }
        )
      },
		}
	}
</script>

<style lang="scss">
	.content{
    box-sizing: border-box;
    overflow: auto;
    padding-bottom: 220rpx;
    .addressBox{
      padding: 0;
      border-radius: 20rpx;
      background: #fff;
      margin: 30rpx;
      overflow: hidden;
      position: relative;
      .des{
        padding: 30rpx 20rpx 20rpx;
        flex:1;
        align-items: flex-start;
        flex-direction: column;
        width: 90%;
        .largeAddress{
          font-size: 24rpx;
          justify-content: flex-start;
          align-items: end;
          .choose-box{
            background: #3388FF;
            color: #fff;
            height: 30rpx;
            line-height: 30rpx;
            font-size: 20rpx;
            padding: 2rpx 10rpx;
            margin-right: 10rpx;
            border-radius: 4rpx;
          }
        }
        .destAddress{
          padding: 12rpx 0;
          font-size: 30rpx;
          font-weight: 600;
          white-space: pre-wrap;
        }
        .persion-des{
          justify-content: flex-start;
          color: #666666;
          font-size: 24rpx;
          .name{
            padding-right: 20rpx;
          }
        }
      }
      .status-box{
        width: 60rpx;
        .iconfont{
          font-size: 50rpx;
          color: #DDDDDD;
        }
        .icon-xuanzhong{
          color: #3388FF;
        }
      }
      .edit{
        position: absolute;
        right: 0;
        top: 0;
        padding: 40rpx;
        .iconfont{
          font-size: 40rpx;
          color: #666;

        }
      }
    }
  }
</style>
